package com.sc.controller;

import com.sc.bean.ResultBean;
import com.sc.utils.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "测试")
public class UserController extends BaseController{
    @Autowired
    RedisUtils redisUtils;
    @GetMapping("/login")
    @ApiOperation("测试1")
    public ResultBean login(){
        return new ResultBean<>(200,"成功",null);
    }
    @GetMapping("/test")
    @ApiOperation("测试2")
    public ResultBean test(){
        return new ResultBean<>(200,"成功",null);
    }
    @GetMapping("/redis/test")
    @ApiOperation("redis测试")
    public ResultBean redisTest(){
        Map<String,Object> hashMap = new HashMap<>();
        hashMap.put("test1",123);
        hashMap.put("test2",456);
        redisUtils.hsetKeys("hash",hashMap);
        Object obj = redisUtils.hget("hash","test1");
        List<Object> fileds = new ArrayList<>();
        fileds.add("test2");
        fileds.add("test1");
        Object obj2 = redisUtils.hmget("hash",fileds);
        List<Object> obj3 = redisUtils.hgetAll("hash");
        System.out.println(obj);
        return new ResultBean<>(200,"成功",obj);
    }
}
